<template>
  <div class="college-volunteer">
    <div class="header">
      <img
        src="@/assets/images/goBackImg.png"
        class="back"
        alt="header"
        @click="goBack"
      />
      <div class="title"></div>
    </div>
    <div class="middle">
      <div class="middle-header">
        <div
          :class="
            currentActiveTab.name == item.name
              ? 'filterTabList-item-active'
              : 'filterTabList-item-unactive'
          "
          v-for="(item, index) in filterTabList"
          :key="index"
          @click="changeFilterTabListOption(item)"
        >
          {{ item.name }} {{ item.value }}
          <img
            v-if="currentActiveTab == index"
            class="bottom-path-left"
            :src="bottomPath"
            alt=""
          />
          <img
            v-if="currentActiveTab == index"
            class="bottom-path-right"
            :src="bottomPath"
            alt=""
          />
        </div>
      </div>
      <div class="table-container">
        <CollegeList
          :currentActiveTab="currentActiveTab"
          @update-data="handleUpdateFourNum"
        ></CollegeList>
      </div>
    </div>
  </div>
</template>

<script setup>
import { reactive, ref } from 'vue';
import { useRouter } from 'vue-router';
import bottomPath from '@/assets/images/bottomPath.png';
import CollegeList from './components/CollegeList.vue';

defineOptions({
  name: 'CollegeVolunteer',
});

const router = useRouter();

const filterTabList = reactive([
  {
    name: '冲',
    value: '',
    key: '10',
  },
  {
    name: '稳',
    value: '',
    key: '20',
  },
  {
    name: '保',
    value: '',
    key: '30',
  },
  {
    name: '全部',
    value: '',
    key: '',
  },
]);

const currentActiveTab = ref({
  name: '冲',
  value: '',
  key: '10',
});
const changeFilterTabListOption = (item) => {
  currentActiveTab.value = item;
};

// 更新四个数字
const handleUpdateFourNum = (newData) => {
  // 0: "全部",
  // 10: "可冲击",
  // 30: "可保底",
  // 20: "较稳妥",
  filterTabList[0].value = newData[10];
  filterTabList[1].value = newData[20];
  filterTabList[2].value = newData[30];
};

const goBack = () => {
  router.go(-1);
};
</script>

<style lang="scss" scoped>
.college-volunteer {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #dff0ff;
  .header {
    display: flex;
    align-items: center;
    position: relative;
    flex-shrink: 0;
    padding: 30px 32px 0 32px;
    .back {
      width: 40px;
      height: 40px;
    }
    .home {
      margin-left: 24px;
    }
    .top-select {
      height: 50px;
      background: #d7e9f8;
      border-radius: 40px;
      border: 4px solid #ffffff;
      display: flex;
      align-items: center;
      .top-select-item {
        height: 100%;
        text-align: center;
        border-radius: 34px;
        font-family: PingFang-SC, PingFang-SC;
        font-size: 22px;
        color: #000;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        width: 250px;
      }
      .top-select-item-active {
        font-size: 24px;
        font-weight: bold;
        background: #ffffff;
        @extend .top-select-item;
        transition: all 0.1s ease;
      }
    }
  }
  .middle {
    margin-top: -32px;
    display: flex;
    flex-direction: column;
    .middle-header {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 54%;
      overflow: hidden;
      margin: 0 auto;
      flex-shrink: 0;
      .filterTabList-item {
        width: 25%;
        height: 54px;
        font-family: PingFang-SC, PingFang-SC;
        font-weight: bold;
        font-size: 24px;
        border-radius: 18px 18px 0px 0px;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        position: relative;
      }
      .filterTabList-item-unactive {
        @extend .filterTabList-item;
        color: #000;
      }
      .filterTabList-item-active {
        @extend .filterTabList-item;
        color: #fff;
        background: $primary-color;
      }
      .bottom-path-left {
        width: 33px;
        height: 30px;
        position: absolute;
        left: -33px;
        top: 45px;
        transform: scaleX(-1);
      }
      .bottom-path-right {
        width: 33px;
        height: 30px;
        position: absolute;
        right: -33px;
        top: 45px;
      }
    }
    .table-container {
      box-sizing: border-box;
      overflow: hidden;
      position: relative;
      padding: 0 32px;
      background-color: #d4e6f9;
      border-radius: 15px;
      &::-webkit-scrollbar {
        width: 24px;
      }
      &::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.2);
        border-radius: 22px;
      }
    }
  }
}
</style>
